define(["jquery", "easy-admin", "treetable"], function ($, ea) {
    var table = layui.table,
        treetable = layui.treetable;
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.order/index',
        edit_url: 'mall.order/edit',
        export_url: 'mall.order/export'
    };
    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                height:'full-50',
                toolbar: ['refresh',
                    [],
                    'export'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id',width: 60,search:false},
                    {field: 'order_sn', title: '订单号', width: 220},
                    {field: 'wechat.nickName', title: '下单用户', width: 90},
                    {field: 'machine_id', title: '机器编号', width: 160},
                    {field: 'machine.machine_name', title: '机器名称', width: 90},
                    {field: 'mode', title: '支付方式', width: 90,selectList: {0:"未支付",1:"微信支付"}},
                    {field: 'cate.title', title: '代理商', width: 90},
                    {field: 'total', title: '商品数量', width: 90,search:false},
                    {field: 'order_price', title: '商品金额',search: false, templet: ea.table.price, width: 90},
                    {field: 'pay_price', title: '应付金额',search:false,width:90,templet: ea.table.price},
                    {field: 'order_status', title: '支付状态',search:'select',width:100,selectList: {"0":"待支付","1":"已支付","2":"待收货","3":"已完成","4":"售后/退款","9":"已取消"}},
                    {field: 'd_status', title: '取餐状态',search:'select',width:100,selectList: {"0":"未知","1":"等待制作","2":"正在制作","3":"制作完成","4":"已取餐","9":"已取消"}},
                    {field: 'create_time', title: '下单时间', width:170,search: 'range'},
                    {
                        width: 200,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '订单详情',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            }],
                        ]
                    }
                ]],
            });
            ea.listen();
        },
        edit:function (){
            ea.listen();
        }
    }
    return Controller;
});